home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-12-22 | 4.0 KB | 167 lines | [TEXT/MPS ] |
- {******************************************************************************
- **
- ** Project Name: DropInfo
- ** File Name: DIUtils.p
- **
- ** Description: Generic utility routines used by DropInfo
- **
- *******************************************************************************
- ** A U T H O R I D E N T I T Y
- *******************************************************************************
- **
- ** Initials Name
- ** -------- -----------------------------------------------
- ** SCS Stephan Somogyi
- ** LDR Leonard Rosenthol
- **
- *******************************************************************************
- ** R E V I S I O N H I S T O R Y
- *******************************************************************************
- **
- ** Date Time Author Description
- ** -------- ----- ------ ---------------------------------------------
- ** 12/22/91 LDR Ported to Pascal
- ** 29.22.91 SCS Original Version scavenged from MyMacStuff parts
- **
- ******************************************************************************}
- UNIT DIUtils;
- INTERFACE
-
- {$IFC THINK_Pascal}
- USES
- Aliases, AppleEvents, PPCToolbox, Processes, Script, DSGlobals; {just the DropShell files}
- {$ELSEC}
- USES
- { First load standard interface files}
- MemTypes, QuickDraw,
-
- { Now include the stuff from OSIntf }
- OSIntf,
-
- { Now Include the stuff from ToolIntf.p }
- ToolIntf, Packages, GestaltEqu,
-
- { Then any OTHER Toolbox interfaces... }
- Files, Aliases, AppleEvents, PPCToolbox, Processes,
-
- { And finally any files from DropShell }
- DSGlobals;
- {$ENDC THINK_Pascal}
-
- PROCEDURE FlashItem(pDial:DialogPtr; pItem: integer);
-
- PROCEDURE DisEnAble(pDial:DialogPtr; pItem: integer; on: Boolean);
- PROCEDURE CheckBox(pDial:DialogPtr; pItem: integer; on: Boolean);
-
- PROCEDURE GetTxtItem(pDial:DialogPtr; pItem: integer; VAR txt: Str255);
- PROCEDURE SetTxtItem(pDial:DialogPtr; pItem: integer; txt: Str255);
-
- PROCEDURE DefBut(dptr: DialogPtr);
-
- IMPLEMENTATION
-
- {
- Flashes an item, in DropInfo's case a button, briefly. Used to show the
- effect of a kbd-shortcut.
- }
- PROCEDURE FlashItem(pDial:DialogPtr; pItem: integer);
- VAR
- lType: integer;
- lHndl: Handle;
- lBox: Rect;
- lDummy: longint;
- BEGIN
- GetDItem(pDial, pItem, lType, lHndl, lBox);
- IF (ControlHandle(lHndl)^^.contrlHilite <> 255) THEN
- BEGIN
- HiliteControl(ControlHandle(lHndl), 1);
- Delay(8, lDummy);
- HiliteControl(ControlHandle(lHndl), 0);
- END;
- END;
-
-
- {
- Disables or enables a item in a dialog box depending on the state of the
- parameter "on".
- }
- PROCEDURE DisEnAble(pDial:DialogPtr; pItem: integer; on: Boolean);
- VAR
- lType: integer;
- lHndl: Handle;
- lBox: Rect;
- BEGIN
- GetDItem(pDial, pItem, lType, lHndl, lBox);
- IF (on) THEN
- HiliteControl(ControlHandle(lHndl), 0)
- ELSE
- HiliteControl(ControlHandle(lHndl), 255);
- END;
-
-
- {
- Checks or unchecks either a checkbox or a radio button depending on the
- state of the parameter "on".
- }
- PROCEDURE CheckBox(pDial:DialogPtr; pItem: integer; on: Boolean);
- VAR
- lType: integer;
- lHndl: Handle;
- lBox: Rect;
- BEGIN
- GetDItem(pDial, pItem, lType, lHndl, lBox);
- IF (on) THEN
- SetCtlValue(ControlHandle(lHndl), 1)
- ELSE
- SetCtlValue(ControlHandle(lHndl), 0);
- END;
-
-
- { Gets the contents of the dialog text item specified }
- PROCEDURE GetTxtItem(pDial:DialogPtr; pItem: integer; VAR txt: Str255);
- VAR
- lType: integer;
- lHndl: Handle;
- lBox: Rect;
- BEGIN
- GetDItem(pDial, pItem, lType, lHndl, lBox);
- GetIText(lHndl, txt);
- END;
-
-
- { Sets the contents of the dialog text item specified }
- PROCEDURE SetTxtItem(pDial:DialogPtr; pItem: integer; txt: Str255);
- VAR
- lType: integer;
- lHndl: Handle;
- lBox: Rect;
- BEGIN
- GetDItem(pDial, pItem, lType, lHndl, lBox);
- SetIText(lHndl, txt);
- END;
-
-
- { Creates the standard outline around a dialog's default item }
- PROCEDURE DefBut(dptr: DialogPtr);
- VAR
- lType: integer;
- lHndl: Handle;
- lBox: Rect;
- oldPen: PenState;
- oldPort: GrafPtr;
- BEGIN
- GetPenState(oldPen);
- GetPort(oldPort);
- SetPort(dptr);
-
- GetDItem(dptr, DialogPeek(dptr)^.aDefItem, lType, lHndl, lBox);
- InsetRect(lBox, -4, -4);
- PenSize(3, 3);
- FrameRoundRect(lBox, 16, 16);
-
- SetPort(oldPort);
- SetPenState(oldPen);
- END;
-
- END.
-